package edu.njust.cma.service.impl;

import edu.njust.cma.mapper.SmallProjectMapper;
import edu.njust.cma.mapper.StandardMapper;
import edu.njust.cma.pojo.SmallProject;
import edu.njust.cma.pojo.Standard;
import edu.njust.cma.service.SmallProjectService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Map;

@Service
public class SmallProjectServiceImpl implements SmallProjectService {

    @Autowired
    SmallProjectMapper smallProjectMapper;
    @Autowired
    StandardMapper standardMapper;

    @Override
    public Map<Integer,Standard> getSmallProject(Integer projectId) {
        Map<Integer,Standard> map = new java.util.HashMap<>();
        var smallProjectList = smallProjectMapper.getSmallProject(projectId);
        for (SmallProject smallProject : smallProjectList) {
            var standard = standardMapper.getStandardById(smallProject.getStandardId());
            map.put(smallProject.getId(),standard);
        }
        return map;
    }

}
